package com.daidai.activitys

import android.graphics.drawable.AnimationDrawable
import android.widget.ImageView
import com.daidai.base.BaseActivity
import com.daidai.spinner.R

class FrameAnimationActivity : BaseActivity() {

    lateinit var ivView:ImageView

    override fun getContentViewResId() = R.layout.activity_frameanim

    override fun initView() {
        ivView = findViewById(R.id.ivView)
        playAnim(R.drawable.sport_zoulu)

        findBtn(R.id.btnYuanditiao).setOnClickListener { playAnim(R.drawable.sport_yuanditiao) }
        findBtn(R.id.btnPingPang).setOnClickListener { playAnim(R.drawable.sport_pingpongqiu) }
        findBtn(R.id.btnFootBall).setOnClickListener { playAnim(R.drawable.sport_tizuqiu) }
        findBtn(R.id.btnBasketBall).setOnClickListener { playAnim(R.drawable.sport_lanqiu) }
        findBtn(R.id.btnRunning).setOnClickListener { playAnim(R.drawable.sport_paobu) }
        findBtn(R.id.btnJianshencao).setOnClickListener { playAnim(R.drawable.sport_jianshencao) }
    }

    override fun initData() {

    }


    fun playAnim(resId:Int){
        ivView.setImageResource(resId)
        (ivView.drawable as AnimationDrawable).start()
    }
}